Load libraries and data sets from separate script
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✓ ggplot2 3.3.5 ✓ purrr 0.3.4
## ✓ tibble 3.1.5 ✓ dplyr 1.0.7
## ✓ tidyr 1.1.4 ✓ stringr 1.4.0
## ✓ readr 2.0.1 ✓ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(hrbrthemes)
library(plotly)
##
## Attache Paket: 'plotly'
## Das folgende Objekt ist maskiert 'package:ggplot2':
##
## last_plot
## Das folgende Objekt ist maskiert 'package:stats':
##
## filter
## Das folgende Objekt ist maskiert 'package:graphics':
##
## layout
library(viridis)
## Lade nötiges Paket: viridisLite
source("98_data-wrangling-scripts/glimpse_eurostat_data.R")
source("98_data-wrangling-scripts/glimpse_covid_measures_index_europe.R")
##
## Attache Paket: 'lubridate'
## Die folgenden Objekte sind maskiert von 'package:base':
##
## date, intersect, setdiff, union
## Warning in Code == Europe_iso: Länge des längeren Objektes
## ist kein Vielfaches der Länge des kürzeren Objektes
## Warning in iso_code == Europe_iso: Länge des längeren Objektes
## ist kein Vielfaches der Länge des kürzeren Objektes
## Joining, by = "Month"
Mutating data sets
#glimpse(eurostat_total_percent)
tourism_total_graph <- eurostat_total_percent %>%
pivot_longer(., cols= 2:22, names_to = "year", values_to = "tourist_stays_percent") %>%
filter(States == "European Union - 27 countries (from 2020)") %>%
mutate(Month = lubridate::ym(year)) %>%
arrange(Month)
#glimpse(tourism_total_graph)
#glimpse(data_covid_measures)
#Join dataframes and filter Jan/Feb 2020 to only get the pandemic-time-series
tourism_total_graph_02 <- left_join(
tourism_total_graph, covid_stats) %>%
filter(!year == c("2020-01", "2020-02"))
## Joining, by = "Month"
## Warning in year == c("2020-01", "2020-02"): Länge des längeren Objektes
## ist kein Vielfaches der Länge des kürzeren Objektes
First glimpse at data
p <- tourism_total_graph_02 %>%
ggplot(aes(x=Month)) +
geom_line(aes(y = tourist_stays_percent), color = "#404788FF") +
geom_line(aes(y = mean_month_measures), color="#20A387FF") +
scale_y_continuous(limits = c(-100, 100), breaks = c(-100, -75, -50, -25, 0, 25, 50, 75, 100),
name = "Change (in %) / Covid-Measures (Index 0-100)") +
scale_x_date(limits = as.Date(c("2020-03-01","2021-09-01")),
date_breaks = "3 month",
date_minor_breaks = "month",
date_labels = "%b (%y)") +
xlab('Timeline of the Pandemic (Mar 2020 - Sep 2021)') +
theme_ipsum() +
theme(
axis.title.x = element_text(size=10),
axis.title.y = element_text( size=10),
axis.title.y.right = element_text(color = "#20A387FF", size=10)
)
#p
p <- p %>% style(hoverinfo = "y")
ggplotly(p)